public class ArrayDemo{
    public static void main(String[] arg){
        int x[] = {7,3,6,9,8};
        //int x[] = new int[5]; 
        //System.out.println("x[0] = " + x[0]);
        //System.out.println("x[2] = " + x[2]); 
        //System.out.println("x[1] = " + x[1]);
        //System.out.println("x[2] = " + x[2]);
        //System.out.println("the length of the x[] :" + x.length);
        printArray(x);
        int max = findMax(x);
        System.out.println("the max number is " + max);
        bubbleSort(x);
    } 
    public static void printArray(int x[]){
        for(int i = 0;i<x.length;i++){
            System.out.println("number" + (i+1) + " is " + x[i]);
        }
    }
    public static int findMax(int a[]){
        int temp = a[0];
        for(int j = 1;j<a.length;j++ ){
            if(temp<a[j]){
                temp = a[j];
            } 
        }
        return temp;
    }
    public static void bubbleSort(int x[]){
        for(int i=0;i<x.length-1;i++){
            for(int j = 0;j<x.length-1-i;j++){
                if (x[j]<x[j+1]){
                    int temp = x[j];
                    x[j] = x[j+1];
                    x[j+1] = temp; 
                }
            }

        }
        printArray(x);
    }
} 